from django.urls import path
from . import views
from . import views_optimized

app_name = 'projects'

urlpatterns = [
    path('', views.dashboard, name='dashboard'),
    # 优化版仪表盘
    path('optimized-dashboard/', views_optimized.optimized_dashboard, name='optimized_dashboard'),
    # 切换到优化版仪表盘
    path('switch-to-optimized/', views_optimized.switch_to_optimized_dashboard, name='switch_to_optimized'),
    # 仪表盘数据API
    path('api/dashboard-data/', views_optimized.api_dashboard_data, name='api_dashboard_data'),
    # 消息列表API
    path('api/message-list/', views_optimized.api_message_list, name='api_message_list'),
    path('projects/', views.project_list, name='project_list'),
    path('create/', views.project_create, name='project_create'),
    path('<int:project_id>/', views.project_detail, name='project_detail'),
    path('<int:project_id>/update/', views.project_update, name='project_update'),
    path('<int:project_id>/delete/', views.project_delete, name='project_delete'),
    path('<int:project_id>/members/', views.project_members, name='project_members'),
    path('<int:project_id>/members/add/', views.project_add_member, name='project_add_member'),
    path('<int:project_id>/members/<int:member_id>/remove/', views.project_remove_member, name='project_remove_member'),
    path('<int:project_id>/members/<int:member_id>/update/', views.project_update_member, name='project_update_member'),
    path('<int:project_id>/tags/', views.project_tags, name='project_tags'),
    path('<int:project_id>/tags/add/', views.project_add_tag, name='project_add_tag'),
    path('<int:project_id>/tags/<int:tag_id>/delete/', views.project_delete_tag, name='project_delete_tag'),
    
    # API端点
    path('api/webhooks/', views.api_webhooks, name='api_webhooks'),
    
    # webhook URL展示页面
    path('webhook-urls/', views.webhook_urls, name='webhook_urls'),
    
    # 其他webhook相关路径保持不变
    path('<int:project_id>/webhooks/', views.project_webhooks, name='project_webhooks'),
    path('<int:project_id>/webhooks/add/', views.project_add_webhook, name='project_add_webhook'),
    path('<int:project_id>/webhooks/<uuid:webhook_id>/edit/', views.project_edit_webhook, name='project_edit_webhook'),
    path('<int:project_id>/webhooks/<uuid:webhook_id>/delete/', views.project_delete_webhook, name='project_delete_webhook'),
    
    # 接收Webhook请求的URL - 支持多种格式
    path('webhooks/<str:project_slug>/<uuid:webhook_id>/receive/', views.receive_webhook, name='receive_webhook'),
    path('webhooks/<int:project_id>/<str:webhook_id>/receive/', views.receive_webhook_alt, name='receive_webhook_alt'),
    # 简单测试URL（用于调试）
    path('test-webhook/<int:project_id>/<str:webhook_id>/', views.test_webhook, name='test_webhook'),
    
    # 公告管理URL - 管理员专用
    path('announcements/', views.announcement_list, name='announcement_list'),
    path('announcements/create/', views.announcement_create, name='announcement_create'),
    path('announcements/<int:announcement_id>/edit/', views.announcement_edit, name='announcement_edit'),
    path('announcements/<int:announcement_id>/delete/', views.announcement_delete, name='announcement_delete'),
    
    # 项目公告URL
    path('<int:project_id>/announcements/', views.project_announcements, name='project_announcements'),
    
    # 消息管理URL
    path('<int:project_id>/messages/', views.message_list, name='message_list'),
    path('<int:project_id>/messages/<int:message_id>/', views.message_detail, name='message_detail'),
    path('<int:project_id>/messages/<int:message_id>/toggle-status/', views.message_toggle_status, name='message_toggle_status'),
    path('<int:project_id>/messages/bulk-update/', views.message_bulk_update, name='message_bulk_update'),
]